package com.jnevision.overtimeapproval.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.ApiController;
import com.baomidou.mybatisplus.extension.api.R;
import com.jnevision.leaveapprovalrecords.model.LeaveApprovalRecords;
import com.jnevision.leaveapprovalrecords.service.LeaveApprovalRecordsServiceImpl;
import com.jnevision.overtimeapproval.model.OvertimeApprovalRecords;
import com.jnevision.overtimeapproval.service.OvertimeApprovalRecordsServiceImpl;
import com.jnevision.replacecardapprovalrecords.model.ReplaceCardApprovalRecords;
import com.jnevision.replacecardapprovalrecords.service.ReplaceCardApprovalRecordsServiceImpl;
/**
 * <p>
 * 加班审批记录 前端控制器
 * </p>
 *
 * @author gavin
 * @since 2019-07-14
 */
@RestController
@RequestMapping("/overtimeapprovals")
public class OvertimeApprovalRecordsController extends ApiController {

	@Autowired
	private OvertimeApprovalRecordsServiceImpl approvalRecordsServiceImpl;
	
	@Autowired
	private ReplaceCardApprovalRecordsServiceImpl replaceCardApprovalRecordsServiceImpl;
	
	
	@Autowired
	private LeaveApprovalRecordsServiceImpl leaveApprovalRecordsServiceImpl;
	  
    @GetMapping("/auditstatus")
    public R<Integer> auditStatus (Integer result) {
    	
    	Integer num = 0;
    	if (result==1) {
    		num+=this.approvalRecordsServiceImpl.count(new QueryWrapper<OvertimeApprovalRecords>().eq("result", result));
    		num+=this.replaceCardApprovalRecordsServiceImpl.count(new QueryWrapper<ReplaceCardApprovalRecords>().eq("result", result));
    		num+=this.leaveApprovalRecordsServiceImpl.count(new QueryWrapper<LeaveApprovalRecords>().eq("result", result));
    	}else {
    		num+=this.approvalRecordsServiceImpl.count(new QueryWrapper<OvertimeApprovalRecords>().ne("result", 1));
    		num+=this.replaceCardApprovalRecordsServiceImpl.count(new QueryWrapper<ReplaceCardApprovalRecords>().ne("result", 1));
    		num+=this.leaveApprovalRecordsServiceImpl.count(new QueryWrapper<LeaveApprovalRecords>().ne("result", 1));
    	}
    	return this.success(num);
    }
	
}

